var common = require('../../common.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    rid:0,
    images: [],
    area: 0,
    bed: 0,
    desc: '',
    people: 2,
    roomName: '',
    price: 0,
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log(options)
    this.data.rid = options.rid;
    var that=this;
     common.request({
       url: 'c=Game&a=getRoomDetail',
       data:{rid:this.data.rid},
       method: 'POST',
       header: { 'content-type': 'application/json' },
       success: function (ret) {
         if (ret.status != 0) {
           wx.showModal({
             title: '错误',
             content: '获取数据失败',
           });
           return false;
         }
         let images=ret.data.album.split(',');
         console.log(images)
         var price, delPrice;
         if (ret.data.price>0){
           price = '¥'+ret.data.price;
           delPrice = '¥' + (ret.data.price+123);
         } else if (ret.data.price == 0){
           price = "免费";
           delPrice = '';
         }else{
           price = "今日不可预订，试试其它日子";
           delPrice = '';
         }

         that.setData({
           rid:that.data.rid,
           images:images,
           area: ret.data.area,
           bed: ret.data.bed,
           desc: ret.data.desc,
           people: ret.data.people,
           roomName: ret.data.roomName,
           price: price,
           delPrice:delPrice,
         })


       },
       fail: function (error) {
       },
       complete: function () {
         wx.hideLoading();
       }
     })
  },
  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
    return {
      title: this.data.roomName,
      desc: '',
      path: 'pages/room/detail?rid='+this.data.rid,
      success: function (res) {
        console.log('shareReturn', res);
      },
      fail: function (ret) {
        console.log('cancelShare', ret);
      }
    }
  },
  goBook:function(){
    wx.navigateTo({
      url: '../booking/calendar?rid='+this.data.rid,
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})